package com.dhms.vostok1.database.check_instrument

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.dhms.vostok1.data.spot_patrol.CheckInstrumentSpeedData
import kotlinx.coroutines.flow.Flow

@Dao
interface CheckInstrumentDao {

    @Query("SELECT * FROM check_instrument_speed WHERE model = :model and minimum_rpm <= :rpm ORDER BY minimum_rpm DESC")
    fun getCheckInstrumentSpeedSheet(
        model: String,
        rpm: Long
    ): Flow<List<CheckInstrumentSpeedData>>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertCheckInstrumentSpeedSheet(data: List<CheckInstrumentSpeedData>)
}